﻿using System.Collections.Generic;
using System.Linq;
using Complaint.Models.Dtos;
using Complaint.Models.Dtos.Enums;
using Complaint.Repositories;

namespace Complaint.Models
{
    public class OrganisationModel : BaseModel<OrganisationRepository>,
        IModel<Organisation>
    {
        #region Implementation of IModel<Organisation>

        public IList<Organisation> Retrieve()
        {

            return Repository.FindAll().ToList();
        }

        public void Create(Organisation dto)
        {

            if (dto != null) Repository.Create(dto);
        }

        public void Update(Organisation dto)
        {

            if (dto != null) Repository.Update(dto);
        }

        public void Delete(Organisation dto)
        {

            if (dto != null) Repository.Delete(dto);
        }

        public IList<Organisation> FindByName(string name)
        {

            return Repository.FindByName(name).ToList();
        }

        public Organisation FindById(int id)
        {

            return Repository.FindById(id);
        }

        #endregion

        public IList<Organisation> Retrieve(int pageNumber, int pageSize)
        {
            return Repository.FindAll(pageNumber, pageSize).ToList();
        }

        public Organisation FindById(int id, LoadOrganisation loadOption)
        {

            return Repository.FindById(id, loadOption);
        }

        public IList<Organisation> FindByCategory(int categoryId)
        {

            return Repository.FindByCategory(categoryId).ToList();
        }

        public IList<Organisation> FindByKeywords(string keywords, LoadOrganisation loadOption)
        {
            return Repository.FindByKeywords(keywords, loadOption).ToList();
        }
    }
}